package com.fire.control.system.entity;

import java.util.Collection;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.fasterxml.jackson.annotation.JsonManagedReference;

/***
 * 
 * @ClassName:  DeviceGroup   
 * @Description:设备组
 * @author:   chenchuang
 * @date:   2017年5月6日 下午3:01:33   
 *
 */
@Entity
@Table(name = "t_device_group")
public class DeviceGroup extends BaseEntity{

	private static final long serialVersionUID = 1L;
	
	/**   
	 * @Fields groupName : 组名
	 */ 
	@Column(name = "group_name", nullable = false,length=50)
	private String groupName;
	
	/**   
	 * @Fields desc : 描述 
	 */ 
	@Column(name = "group_desc")
	private String groupDesc;
	
	/**   
	 * @Fields desc : 经度 
	 */ 
	@Column(name = "longitude")
	private Double longitude;
	
	/**   
	 * @Fields parentId 
	 */
	@Column(name = "parent_id", nullable = false,length=50)
	private String parentId;
	
	/**   
	 * @Fields desc : 纬度 
	 */ 
	@Column(name = "latitude")
	private Double latitude;
	/**   
	 * @Fields company : 所属公司
	 */ 
	@JsonManagedReference
	@ManyToOne(fetch=FetchType.EAGER,optional=false)
	@JoinColumn(name = "company_id")
	private Company company;
	
	/**   
	 * @Fields devices : 设备
	 */ 
	@JsonBackReference
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "deviceGroup")
	private Collection<Device> devices;
	
	/**   
	 * @Fields area : 区域
	 */ 
	@OneToOne(cascade={CascadeType.REFRESH},fetch=FetchType.EAGER,optional=false)  
	@JoinColumn(name="area_id")
	private Area area;
	
	@Column(name = "province_id")
	private String provinceId;//省
	
	@Column(name = "city_id")
	private String cityId;//市
	
	/**   
	 * @Fields address : 所在地址(详细地址)
	 */ 
	@Column(name = "address", nullable = false,length=50)
	private String address;
	
	
	
	public Area getArea() {
		return area;
	}

	public void setArea(Area area) {
		this.area = area;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getParentId() {
		return parentId;
	}

	public void setParentId(String parentId) {
		this.parentId = parentId;
	}

	public String getGroupName() {
		return groupName;
	}

	public void setGroupName(String groupName) {
		this.groupName = groupName;
	}
	

	public String getGroupDesc() {
		return groupDesc;
	}

	public void setGroupDesc(String groupDesc) {
		this.groupDesc = groupDesc;
	}

	public Company getCompany() {
		return company;
	}

	public void setCompany(Company company) {
		this.company = company;
	}

	public Collection<Device> getDevices() {
		return devices;
	}

	public void setDevices(Collection<Device> devices) {
		this.devices = devices;
	}

	public Double getLongitude() {
		return longitude;
	}

	public void setLongitude(Double longitude) {
		this.longitude = longitude;
	}

	public Double getLatitude() {
		return latitude;
	}

	public void setLatitude(Double latitude) {
		this.latitude = latitude;
	}

	public String getProvinceId() {
		return provinceId;
	}

	public void setProvinceId(String provinceId) {
		this.provinceId = provinceId;
	}

	public String getCityId() {
		return cityId;
	}

	public void setCityId(String cityId) {
		this.cityId = cityId;
	}

}
